// import Home from '@/pages/Home';
// import Login from '@/pages/Login';
// import Register from '@/pages/Register';
// import Search from '@/pages/Search';
// import Detail from '@/pages/Detail';
// import AddCartSuccess from '@/pages/AddCartSuccess'
// import ShopCart from '@/pages/ShopCart'
// import Trade from '@/pages/Trade'
// import Pay from '@/pages/Pay'
// import PaySuccess from '@/pages/PaySuccess'
// import Center from '@/pages/Center'
import { Message } from 'element-ui';
// const Home = ()=> import('@/pages/Home')
const Search = ()=> import('@/pages/Search')
const Login = ()=> import('@/pages/Login')
const Register = ()=> import('@/pages/Register')
const Detail = ()=> import('@/pages/Detail')
const ShopCart = ()=> import('@/pages/ShopCart')
const AddCartSuccess = ()=> import('@/pages/AddCartSuccess')
const Trade = ()=> import('@/pages/Trade')
const Pay = ()=> import('@/pages/Pay')
const PaySuccess = ()=> import('@/pages/PaySuccess')
const Center = ()=> import('@/pages/Center')

export default [
  {
    name: 'home',
    path: '/home',
    // component: Home,
    component: ()=> import('@/pages/Home'),
    meta: {
      isHiddenNav: true
    }
  },
  {
    name: 'login',
    path: '/login',
    component: Login,
    meta: {
      isHiddenFooter: true
    }
  },
  {
    name: 'register',
    path: '/register',
    component: Register,
    meta: {
      isHiddenFooter: true
    }
  },
  {
    name: 'search',
    path: '/search/:keyword?', // ?在这里表示前面的数据有可能有 有可能没有
    component: Search
  },
  {
    // 详情页面
    name: 'detail',
    path: '/detail/:skuId',
    component: Detail,
    props: true
  },
  {
    // 添加购物车成功的界面
    name:'addCartSuccess',
    path: '/addCartSuccess',
    component: AddCartSuccess,
    // beforeEnter: (to, from, next) => {
    //   // 判断一下当前跳转过来的上一个页面是不是详情页面
    //   // console.log(to,from)
    //   // 如果上一个页面是详情页面 并且有参数传递 则放行
    //   if (from.name === 'detail' && to.query.skuNum) {
    //     next() // 放行
    //   } else {
    //     Message.error('非法访问...')
    //     next(false) // 不向下执行
    //   }
    // }
  },
  {
    // 购物车路由及组件
    name: 'shopCart',
    path: '/shopCart',
    component:ShopCart
  },
  {
    // trade 结算中心
    name: 'trade',
    path: '/trade',
    component:Trade
  },
  {
    // pay 支付中心
    name: 'pay',
    path: '/pay',
    component:Pay
  },
  {
    // paysuccess 支付成功
    name: 'paySuccess',
    path: '/paySuccess',
    component:PaySuccess
  },
  {
    // center 订单中心
    name: 'center',
    path: '/center',
    component:Center
  },
  {
    path: '/',
    redirect: '/home' // 重定向到主页面
  }
];
